package com.hunanwenli.email;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;



/**
 * @author wanzhenyu
 * @date 2021/5/30 13:33
 */
@Component
public class SendSms {


    private static final Logger logger = Logger.getLogger(SendSms.class);
    @Value("${spring.mail.username}")
    private String from;

            @Autowired
            private JavaMailSender mailSender;
            /**
             * 简单文本邮件
             * @param to 接收者邮件
             * @param subject 邮件主题
             * @param contnet 邮件内容
             */
            public void sendSimpleMail(String to, String subject, String contnet){
                SimpleMailMessage message = new SimpleMailMessage();
                message.setTo(to);
                message.setSubject(subject);
                message.setText(contnet);
                message.setFrom(from);
                mailSender.send(message);
                logger.debug(to+"发送短信成功");
            }



}
